package com.demoo.zjsu.service.smartwebsite.zjgsu;

import com.demoo.zjsu.model.smartwebsite.PageTwo;
import com.demoo.zjsu.model.smartwebsite.PageTwoContent;
import com.demoo.zjsu.service.smartwebsite.Page;
import com.demoo.zjsu.service.smartwebsite.PageFactory;
import com.demoo.zjsu.service.smartwebsite.PageListFactory;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.stereotype.Service;

/**
 * Created by jshjsh on 2016/8/17.
 * 大事记的处理方法
 */
@Service
public class BigEventService extends PageFactory{


    @Override
    public Elements getOtherMain(Document document) {
        return document.select("table[width=100%]").eq(1).select("tr").eq(1);
    }

    @Override
    public PageTwo dealTitle(String url, String title) {
        PageTwo pageTwo = new PageTwo();
        pageTwo.setKey(url.replace(".html", ""));
        pageTwo.setTitle(title);
        pageTwo.setDate("");
        return pageTwo;
    }

    @Override
    public void filterAgain(Elements elements) {
        elements.select("tr").eq(0).remove();
    }

    @Override
    public PageTwoContent getContent(Elements elements) {
        PageTwoContent content = get(elements);
        content.setThroat("");
        return content;
    }


    @Override
    public Page getPage() {
        Page page = new Page();
        page.setUrl("http://www.hzic.edu.cn/Channel_6/");
        page.setCategory("大事记");
        return page;
    }

    @Override
    public Elements getMain(Document document) {
        return document.select(".line-x").select("[width=84%]");
    }


}
